<?php
 
/*
 * Following code will create a new product row
 * All product details are read from HTTP Post Request
 */
 
// array for JSON response
$response = array();
 
// check for required fields
if (isset($_POST['tengd']) && isset($_POST['sotien']) && isset($_POST['laisuat'])&& isset($_POST['ngaygd'])&& isset($_POST['ghichu'])&& isset($_POST['ngaytra'])&& isset($_POST['magd'])&& isset($_POST['username'])&& isset($_POST['datra'])&& isset($_POST['islai'])) {
 
     $tengd = $_POST['tengd'];
    $sotien = $_POST['sotien'];
	$laisuat = $_POST['laisuat'];
	$ngaygd=$_POST['ngaygd'];
	$ghichu=$_POST['ghichu'];
	$ngaytra=$_POST['ngaytra'];
	$magd=$_POST['magd'];
	$username=$_POST['username'];
	$datra=$_POST['datra'];
	$islai=$_POST['islai'];
    
	
	
 
    // include db connect class
    require_once __DIR__ . '/db_connect.php';
 
    // connecting to db
    $db = new DB_CONNECT();
 
    // mysql inserting a new row
    $result = mysql_query("INSERT INTO `vayno`(`ID`,`TENNGUOIGD`, `SOTIEN`, `LAISUAT`, `NGAYGD`,`GHICHU`,`NGAYTRA`,`MAGD`,`USERNAME`,`DATRA`,`ISLAI`) VALUES (NULL,'$tengd' ,'$sotien','$laisuat','$ngaygd','$ghichu','$ngaytra','$magd','$username','$datra','$islai')");
 
    // check if row inserted or not
    if ($result) {
        // successfully inserted into database
        $response["success"] = 1;
        $response["message"] = "Product successfully created.";
 
        // echoing JSON response
        echo json_encode($response);
    } else {
        // failed to insert row
        $response["success"] = 0;
        $response["message"] = "Oops! An error occurred.";
 
        // echoing JSON response
        echo json_encode($response);
    }
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
    // echoing JSON response
    echo json_encode($response);
}
?>